ALMaSS  1.0
The Animal, Landscape and Man Simulation System
MovementMap Class Reference

Movement maps are used for rapid computing of animal movement. More...

#include <MovementMap.h>

Public Member Functions

int GetMapValue (unsigned x, unsigned y)
 
void SetMapValue (unsigned x, unsigned y, unsigned value)
 
void SetMapValue0 (unsigned x, unsigned y)
 
void SetMapValue1 (unsigned x, unsigned y)
 
void SetMapValue2 (unsigned x, unsigned y)
 
void SetMapValue3 (unsigned x, unsigned y)
 
 MovementMap (Landscape *L, int spref)
 
 ~MovementMap ()
 

Public Attributes

uint32m_TheMap
 
uint32 maxx
 
uint32 maxy
 

Protected Member Functions

void Init (int spref)
 

Protected Attributes

Landscapem_ALandscape
 

Detailed Description

Movement maps are used for rapid computing of animal movement.

Constructor & Destructor Documentation

◆ MovementMap()

MovementMap::MovementMap ( Landscape L,
int  spref 
)
51 {
52  m_ALandscape = L;
53  // must make sure that we have whole words
56  m_TheMap = new uint32[ maxx*maxy ];
57 
58  Init(spref);
59 }
unsigned int uint32
Definition: ALMaSS_Setup.h:34
int SupplySimAreaHeight(void)
Definition: landscape.h:1637
int SupplySimAreaWidth(void)
Definition: landscape.h:1632
Landscape * m_ALandscape
Definition: MovementMap.h:65
uint32 maxx
Definition: MovementMap.h:54
uint32 maxy
Definition: MovementMap.h:55
uint32 * m_TheMap
Definition: MovementMap.h:53
void Init(int spref)
Definition: MovementMap.cpp:69

References Init(), m_ALandscape, m_TheMap, maxx, maxy, Landscape::SupplySimAreaHeight(), and Landscape::SupplySimAreaWidth().

◆ ~MovementMap()

MovementMap::~MovementMap ( )
63 {
64  delete m_TheMap;
65 }

References m_TheMap.

Member Function Documentation

◆ GetMapValue()

int MovementMap::GetMapValue ( unsigned  x,
unsigned  y 
)
410 {
411  uint32 theBit=x & 15;
412  // Multiply by two
413  theBit=theBit<<1;
414  // divide by 16
415  uint32 index= (x>>4)+(maxx*y);
416  return ((m_TheMap[index] >> theBit) & 0x03); // 0-3
417 }

References m_TheMap, and maxx.

Referenced by Bembidion_Adult::MoveTo_quality_assess(), and Bembidion_Adult::MoveToAggr().

◆ Init()

void MovementMap::Init ( int  spref)
protected
70 {
71  char error_num[20];
72  for (int y=0; y<m_ALandscape->SupplySimAreaHeight(); y++)
73  {
74  for (int x=0; x<m_ALandscape->SupplySimAreaWidth(); x++)
75  {
78  uint32 colour=0;
79  if (spref==0)
80  {
81  // Beetle
82  switch (tole)
83  {
84 
85  case tole_Hedges: // 130
86  case tole_RoadsideVerge: // 13
87  case tole_FieldBoundary: // 160
88  case tole_HedgeBank:
89  case tole_BeetleBank:
91  case tole_RoadsideSlope:
93  colour=1;
94  break;
95  case tole_Marsh: // 95
96  case tole_Scrub: // 70
97  case tole_Railway: // 118
98  case tole_PermanentSetaside: // 33
99  case tole_RiversidePlants: // 98
100  case tole_PitDisused: // 75
101  case tole_Garden: //11
102  case tole_Track: // 123
103  case tole_SmallRoad: // 122
104  case tole_LargeRoad: // 121
105  case tole_MetalledPath:
106  case tole_Carpark:
107  case tole_Churchyard:
108  case tole_Saltmarsh:
109  case tole_PlantNursery:
110  case tole_Vildtager:
111  case tole_HeritageSite: colour = 2;
112  case tole_Copse:
114  case tole_WoodlandMargin:
115  case tole_IndividualTree:
116  case tole_RiversideTrees: // 97
117  case tole_DeciduousForest: // 40
118  case tole_MixedForest: // 60
119  case tole_ConiferousForest: // 50
120  case tole_YoungForest:
121  case tole_StoneWall: // 15
122  case tole_ActivePit: // 115
123  case tole_Fence: // 225
124  break;
125  case tole_Field: // 20 & 30
127  case tole_PermPasture: // 35
128  case tole_PermPastureLowYield: // 35
129  case tole_PermPastureTussocky: // 26
131  case tole_Heath:
132  case tole_NaturalGrassDry: // 110
133  case tole_AmenityGrass:
134  case tole_Parkland:
135  case tole_Orchard:
136  case tole_OrchardBand:
137  case tole_MownGrass:
138  case tole_Wasteland: // 209
139  case tole_UnknownGrass:
140  colour=0;
141  break;
142  case tole_Building: // 5
143  case tole_Freshwater: // 90
144  case tole_FishFarm: // 220
145  case tole_Pond:
146  case tole_River: // 96
147  case tole_Saltwater: // 80
148  case tole_Coast: // 100
149  case tole_BareRock: // 59
150  case tole_UrbanNoVeg:
151  case tole_UrbanVeg:
152  case tole_UrbanPark:
154  case tole_SandDune:
155  case tole_Stream:
156  case tole_Pylon:
157  case tole_WindTurbine:
158  case tole_DrainageDitch:
159  case tole_Canal:
160  colour = 3;
161  break;
162  case tole_Foobar: // 999 !! type unknown - should not happen
163  default:
164  sprintf( error_num, "%d", tole );
165  g_msg->Warn( WARN_FILE,
166  "MovementMap::Init(): Unknown landscape element type:",
167  error_num );
168  exit( 1 );
169  }
170  }
171  else if (spref==1) { // Partridge
172  switch (tole)
173  {
174  case tole_Hedges: // 130
175  case tole_PermanentSetaside: // 33
176  case tole_RoadsideVerge: // 13
177  case tole_FieldBoundary: // 160
178  case tole_HedgeBank:
179  case tole_BeetleBank:
180  case tole_UnsprayedFieldMargin: // 31
181  case tole_Vildtager:
183  colour=3;
184  break;
185  case tole_Railway: // 118
186  case tole_Scrub: // 70
187  case tole_Field: // 20 & 30
188  case tole_PermPasture: // 35
189  case tole_NaturalGrassDry: // 110
190  case tole_RiversidePlants: // 98
191  case tole_RoadsideSlope:
192  case tole_RiversideTrees: // 97
193  case tole_YoungForest: //55
194  case tole_Wasteland:
195  case tole_UnknownGrass:
196  colour=2;
197  break;
198  case tole_PitDisused: // 75
200  case tole_Marsh: // 95
201  case tole_Garden: //11
202  case tole_Track: // 123
203  case tole_SmallRoad: // 122
204  case tole_LargeRoad: // 121
205  colour=1;
206  break;
207  case tole_IndividualTree:
208  case tole_PlantNursery:
209  case tole_WindTurbine:
211  case tole_WoodlandMargin:
212  case tole_Pylon:
213  case tole_DeciduousForest: // 40
214  case tole_MixedForest: // 60
215  case tole_ConiferousForest: // 50
216  case tole_StoneWall: // 15
217  case tole_Fence: // 225
218  case tole_Building: // 5
219  case tole_ActivePit: // 115
220  case tole_Pond:
221  case tole_Freshwater: // 90
222  case tole_FishFarm:
223  case tole_River: // 96
224  case tole_Saltwater: // 80
225  case tole_Coast: // 100
226  case tole_BareRock: // 59
227  case tole_AmenityGrass:
228  case tole_Parkland:
229  case tole_UrbanNoVeg:
230  case tole_UrbanPark:
232  case tole_SandDune:
233  case tole_Copse:
234  case tole_MetalledPath:
235  case tole_Carpark:
236  case tole_Churchyard:
237  case tole_Saltmarsh:
238  case tole_Stream:
239  case tole_HeritageSite:
240  colour=0;
241  break;
242  case tole_Foobar: // 999 !! type unknown - should not happen
243  default:
244  sprintf( error_num, "%d", tole );
245  g_msg->Warn( WARN_FILE,
246  "MovementMap::Init(): Unknown landscape element type:",
247  error_num );
248  exit( 1 );
249  }
250  } // End partridge
251  else if (spref==2)
252  { // Spider
253  switch ( tole )
254  {
255  case tole_IndividualTree:
256  case tole_WindTurbine:
258  case tole_WoodlandMargin:
259  case tole_Pylon:
261  case tole_MetalledPath:
262  case tole_Carpark:
263  case tole_Churchyard:
264  case tole_Saltmarsh:
265  case tole_HeritageSite:
266  case tole_Hedges:
267  case tole_HedgeBank:
268  case tole_BeetleBank:
269  case tole_Marsh:
273  case tole_RiversideTrees:
275  case tole_MixedForest:
277  case tole_YoungForest:
278  case tole_StoneWall:
279  case tole_Fence:
280  case tole_Building:
281  case tole_ActivePit:
282  case tole_PitDisused:
283  case tole_Scrub:
284  case tole_Track:
285  case tole_SmallRoad:
286  case tole_LargeRoad:
287  case tole_BareRock:
288  case tole_UrbanNoVeg:
289  case tole_SandDune:
290  case tole_Copse:
291  case tole_MownGrass:
292  colour = 2;
293  break;
294  case tole_PlantNursery:
295  case tole_Vildtager:
296  case tole_RoadsideSlope:
297  case tole_PermPasture: //moved from case 2 to case 3
299  case tole_PermPastureTussocky: //moved from case 2 to case 3
300  case tole_RoadsideVerge:
301  case tole_Railway:
302  case tole_FieldBoundary:
303  case tole_Garden:
304  case tole_Coast:
305  case tole_Heath:
306  case tole_AmenityGrass:
307  case tole_Parkland:
309  case tole_UrbanPark:
310  case tole_Wasteland:
312  colour = 3;
313  break;
314  case tole_Pond:
315  case tole_Freshwater:
316  case tole_FishFarm:
317  case tole_River:
318  case tole_Saltwater:
319  case tole_Stream:
320  colour=0;
321  break;
322  case tole_Field: // Special case
323  case tole_UnsprayedFieldMargin: // Special case
324  colour=1;
325  break;
326  default:
327  sprintf( error_num, "%d", tole );
328  g_msg->Warn( WARN_FILE,
329  "MovementMap::Init(): Unknown landscape element type:",
330  error_num );
331  exit( 1 );
332  }// End spider
333  }
334  SetMapValue(x,y,colour);
335  }
336  }
337 }
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1110
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:59
void SetMapValue(unsigned x, unsigned y, unsigned value)
Definition: MovementMap.cpp:341
class MapErrorMsg * g_msg
This pointer provides access the to the internal ALMaSS error message system.
Definition: maperrormsg.cpp:41
@ WARN_FILE
Definition: maperrormsg.h:37
TTypesOfLandscapeElement
Definition: tole_declaration.h:36
@ tole_BareRock
Definition: tole_declaration.h:75
@ tole_PermPastureTussocky
Definition: tole_declaration.h:45
@ tole_Saltmarsh
Definition: tole_declaration.h:88
@ tole_WoodyEnergyCrop
Definition: tole_declaration.h:94
@ tole_DrainageDitch
Definition: tole_declaration.h:105
@ tole_Carpark
Definition: tole_declaration.h:85
@ tole_Coast
Definition: tole_declaration.h:67
@ tole_UrbanNoVeg
Definition: tole_declaration.h:78
@ tole_Stream
Definition: tole_declaration.h:89
@ tole_Saltwater
Definition: tole_declaration.h:66
@ tole_MixedForest
Definition: tole_declaration.h:53
@ tole_HeritageSite
Definition: tole_declaration.h:90
@ tole_WoodlandMargin
Definition: tole_declaration.h:98
@ tole_RoadsideSlope
Definition: tole_declaration.h:83
@ tole_River
Definition: tole_declaration.h:65
@ tole_Canal
Definition: tole_declaration.h:106
@ tole_WaterBufferZone
Definition: tole_declaration.h:108
@ tole_StoneWall
Definition: tole_declaration.h:56
@ tole_Parkland
Definition: tole_declaration.h:77
@ tole_NaturalGrassWet
Definition: tole_declaration.h:87
@ tole_NaturalGrassDry
Definition: tole_declaration.h:48
@ tole_PermPastureTussockyWet
Definition: tole_declaration.h:100
@ tole_UrbanPark
Definition: tole_declaration.h:79
@ tole_Pylon
Definition: tole_declaration.h:96
@ tole_PermanentSetaside
Definition: tole_declaration.h:46
@ tole_Garden
Definition: tole_declaration.h:58
@ tole_Pond
Definition: tole_declaration.h:101
@ tole_Scrub
Definition: tole_declaration.h:42
@ tole_Fence
Definition: tole_declaration.h:57
@ tole_Field
Definition: tole_declaration.h:43
@ tole_Copse
Definition: tole_declaration.h:82
@ tole_PermPasture
Definition: tole_declaration.h:47
@ tole_Hedges
Definition: tole_declaration.h:37
@ tole_Track
Definition: tole_declaration.h:59
@ tole_Heath
Definition: tole_declaration.h:70
@ tole_Freshwater
Definition: tole_declaration.h:64
@ tole_PitDisused
Definition: tole_declaration.h:50
@ tole_FieldBoundary
Definition: tole_declaration.h:40
@ tole_PlantNursery
Definition: tole_declaration.h:95
@ tole_DeciduousForest
Definition: tole_declaration.h:52
@ tole_UrbanVeg
Definition: tole_declaration.h:103
@ tole_ActivePit
Definition: tole_declaration.h:63
@ tole_RiversidePlants
Definition: tole_declaration.h:49
@ tole_Building
Definition: tole_declaration.h:62
@ tole_RoadsideVerge
Definition: tole_declaration.h:38
@ tole_Vildtager
Definition: tole_declaration.h:99
@ tole_Orchard
Definition: tole_declaration.h:71
@ tole_MownGrass
Definition: tole_declaration.h:74
@ tole_YoungForest
Definition: tole_declaration.h:55
@ tole_OrchardBand
Definition: tole_declaration.h:73
@ tole_SmallRoad
Definition: tole_declaration.h:60
@ tole_Churchyard
Definition: tole_declaration.h:86
@ tole_BuiltUpWithParkland
Definition: tole_declaration.h:80
@ tole_AmenityGrass
Definition: tole_declaration.h:76
@ tole_PermPastureLowYield
Definition: tole_declaration.h:44
@ tole_HedgeBank
Definition: tole_declaration.h:68
@ tole_Railway
Definition: tole_declaration.h:39
@ tole_WindTurbine
Definition: tole_declaration.h:97
@ tole_ConiferousForest
Definition: tole_declaration.h:54
@ tole_SandDune
Definition: tole_declaration.h:81
@ tole_Wasteland
Definition: tole_declaration.h:92
@ tole_IndividualTree
Definition: tole_declaration.h:93
@ tole_UnknownGrass
Definition: tole_declaration.h:91
@ tole_Foobar
Definition: tole_declaration.h:111
@ tole_RiversideTrees
Definition: tole_declaration.h:51
@ tole_LargeRoad
Definition: tole_declaration.h:61
@ tole_UnsprayedFieldMargin
Definition: tole_declaration.h:72
@ tole_BeetleBank
Definition: tole_declaration.h:69
@ tole_MetalledPath
Definition: tole_declaration.h:84
@ tole_FishFarm
Definition: tole_declaration.h:102
@ tole_Marsh
Definition: tole_declaration.h:41

References g_msg, m_ALandscape, SetMapValue(), Landscape::SupplyElementType(), Landscape::SupplySimAreaHeight(), Landscape::SupplySimAreaWidth(), tole_ActivePit, tole_AmenityGrass, tole_BareRock, tole_BeetleBank, tole_Building, tole_BuiltUpWithParkland, tole_Canal, tole_Carpark, tole_Churchyard, tole_Coast, tole_ConiferousForest, tole_Copse, tole_DeciduousForest, tole_DrainageDitch, tole_Fence, tole_Field, tole_FieldBoundary, tole_FishFarm, tole_Foobar, tole_Freshwater, tole_Garden, tole_Heath, tole_HedgeBank, tole_Hedges, tole_HeritageSite, tole_IndividualTree, tole_LargeRoad, tole_Marsh, tole_MetalledPath, tole_MixedForest, tole_MownGrass, tole_NaturalGrassDry, tole_NaturalGrassWet, tole_Orchard, tole_OrchardBand, tole_Parkland, tole_PermanentSetaside, tole_PermPasture, tole_PermPastureLowYield, tole_PermPastureTussocky, tole_PermPastureTussockyWet, tole_PitDisused, tole_PlantNursery, tole_Pond, tole_Pylon, tole_Railway, tole_River, tole_RiversidePlants, tole_RiversideTrees, tole_RoadsideSlope, tole_RoadsideVerge, tole_Saltmarsh, tole_Saltwater, tole_SandDune, tole_Scrub, tole_SmallRoad, tole_StoneWall, tole_Stream, tole_Track, tole_UnknownGrass, tole_UnsprayedFieldMargin, tole_UrbanNoVeg, tole_UrbanPark, tole_UrbanVeg, tole_Vildtager, tole_Wasteland, tole_WaterBufferZone, tole_WindTurbine, tole_WoodlandMargin, tole_WoodyEnergyCrop, tole_YoungForest, MapErrorMsg::Warn(), and WARN_FILE.

Referenced by MovementMap().

◆ SetMapValue()

void MovementMap::SetMapValue ( unsigned  x,
unsigned  y,
unsigned  value 
)
342 {
343 
344  uint32 theBit= x & 15; // Identify the bit within 16 possibilities
345 
346  // Multiply by two
347  theBit=theBit<<1; // Double it because we use two bits per location
348 
349  // divide by 16
350  // Calculate index:
351  uint32 index= (x>>4)+(y*maxx); // maxx is the number of uints per row + x/16 because there are 16 locations per uint
352 
353  value &= 0x03;
354  uint32 NewVal = m_TheMap[index] & ~( 0x03 << theBit ); // Make a hole two bits wide at the right location
355  m_TheMap[index] = NewVal | (value << theBit); // Fill the hole
356 
357 }

References m_TheMap, and maxx.

Referenced by Init().

◆ SetMapValue0()

void MovementMap::SetMapValue0 ( unsigned  x,
unsigned  y 
)
362 {
363  uint32 theBit=x & 15;
364  theBit=theBit<<1; // Multiply by two
365  // divide by 16
366  uint32 index= (x>>4)+(y*maxx);
367  m_TheMap[index] &= ~(0x03<< theBit);
368 }

References m_TheMap, and maxx.

◆ SetMapValue1()

void MovementMap::SetMapValue1 ( unsigned  x,
unsigned  y 
)
373 {
374  uint32 theBit=x & 15;
375  theBit=theBit<<1; // Multiply by two
376  // divide by 16
377  uint32 index= (x>>4)+(maxx*y);
378  m_TheMap[index] &= ~(0x03 << theBit);
379  m_TheMap[index] |= (0x01 << theBit);
380 }

References m_TheMap, and maxx.

◆ SetMapValue2()

void MovementMap::SetMapValue2 ( unsigned  x,
unsigned  y 
)
385 {
386  uint32 theBit=x & 15;
387  // Multiply by two
388  theBit=theBit<<1;
389  // divide by 16
390  uint32 index= (x>>4)+(maxx*y);
391  m_TheMap[index] &= ~(0x03 << theBit);
392  m_TheMap[index] |= (0x02 << theBit);
393 }

References m_TheMap, and maxx.

◆ SetMapValue3()

void MovementMap::SetMapValue3 ( unsigned  x,
unsigned  y 
)
398 {
399  uint32 theBit=x & 15;
400  // Multiply by two
401  theBit=theBit<<1;
402  // divide by 16
403  uint32 index= (x>>4)+(maxx*y);
404  m_TheMap[index] |= (0x03 << theBit);
405 }

References m_TheMap, and maxx.

Member Data Documentation

◆ m_ALandscape

Landscape* MovementMap::m_ALandscape
protected

Referenced by Init(), and MovementMap().

◆ m_TheMap

◆ maxx

◆ maxy

uint32 MovementMap::maxy

Referenced by MovementMap().


The documentation for this class was generated from the following files: